package jcommon.chap5_collection.map;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.map.LazyMap;
import org.apache.commons.lang.StringUtils;

public class Lazy {

	public static void main(String[] args) {
		System.out.println("-------- Test lazyMapDemo1 --------");
		lazyMapDemo();
	}
	
	private static void lazyMapDemo() {
		Map lazyMap = LazyMap.decorate(new HashMap(), new Transformer(){
			public Object transform(Object input) {
				String strInput = (String)input;
				return StringUtils.reverse(strInput);
			}
		});
		
		System.out.println(lazyMap.get("qqlin"));
		System.out.println(lazyMap.get("qqmage"));
	}
}
